#ifndef INFINITY_SERVICE_MANAGER_INL
#	define INFINITY_SERVICE_MANAGER_INL

namespace infinity {

template< class T >
static void ServiceManager::createService()
{
	dwAssert(&findServiceHolder(T::Key) == &InvalidHolder, "Invalid call to createService, service is already registered");
	ServiceHolder holder;

	holder.key = T::Key;
	holder.service = new T();
	
	m_services.push_back(holder);
}

inline Service& ServiceManager::getService(const ServiceKey& key)
{
	ServiceHolder& holder = findServiceHolder(key);

	dwAssert(&holder != &InvalidHolder, "Unknown service");
	dwAssert(holder.service != NULL, "Unknown service");

	return *holder.service;
}

template< class T >
inline T& ServiceManager::getService()
{
	ServiceHolder& holder = findServiceHolder(T::Key);

	dwAssert(&holder != &InvalidHolder, "Unknown service");
	dwAssert(holder.service != NULL, "Unknown service");

	return *static_cast< T* >(holder.service);
}

} // namespace infinity

#endif // !INFINITY_SERVICE_MANAGER_INL
